﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using MyBlog.BusinessInterface;
using MyBlog.DataAccessInterface;
using MyBlog.DataEntity;
using MyBlog.Model;

namespace MyBlog.Business
{
    public class BusinessSysInfo : IBusinessSysInfo
    {
        IDALSysInfo _dalSys;
        IUnitOfWork _unitWork;

        public BusinessSysInfo(IDALSysInfo dalSys, IUnitOfWork unitWork)
        {
            _dalSys = dalSys;
            _unitWork = unitWork;
        }
        public void AddAgree(int type)
        {
            _dalSys.Get(type).AgreeCount++;
            _unitWork.Commit();
        }

        public void AddRead(int type)
        {
            _dalSys.Get(type).ReadCount++;
            _unitWork.Commit();
        }

        public SysInfoModel Get(int type)
        {
            return Mapper.Map<SysInfoModel>(_dalSys.Get(type)); 
        }
    }
}
